﻿

//页面初始化方法
function PageInit() {
    //mini.get("tabs2").removeTab(5);//隐藏操作记录
    // EnterControlTheCursorJumps(enterorderExport);
    //--------------陆运整理岗，制单岗没有qp上传权限 begin----------------------

    //if (isQpInput == 1) {
    //    mini.get("btnQpInput").setEnabled(false);
    //}
    if (qpSendStatus == 0 && empId != "f4085f52-dac3-4a59-b567-b3a5f0ce1cc3") {
        mini.get("btnRemoveSendQp").setEnabled(false);
    }
    //--------------陆运整理岗，制单岗没有qp上传权限 end----------------------
    var grid5 = mini.get("datagrid5");
    var grid1 = mini.get("datagrid1");
    grid1.frozenColumns(0, 5);
    grid5.frozenColumns(0, 3);

    //查询报关单隐藏操作按钮
    if (isview == "1") {
        document.getElementById("hiddenButton").style.display = "none";
        $("#btnCopy1").show();
    } else {
        document.getElementById("hiddenButton").style.display = "block";
    }
    fnSetDisabled();
    fnSetDefaultTransWay();
    var trans = mini.get("hidtransport_way").getValue();
    if (trans == "02" || trans == "03") {
        fnLYAddContainerInfo(trans);
    }
    //关务不开放下载
    if (trans == "04") {
        $("#btnQpDownload").hide();
    }

    ////鼠标点击 默认选中 内容  排除  【标记唛码】
    $("input[type='text'],input[type='input'] ").not("input[name^='mark']").not("input[name^='cost_note']").on("click", function () {
        $(this).select();
    });
    $("input[type='text'],input[type='input'] ").not("input[name^='mark']").not("input[name^='cost_note']").on("focus", function () {
        $(this).select();
    });

    $("input").attr("style", "background-color:RGB(223,251,203);");

    var declare_id = mini.get("hiddeclare_id").getValue();
    //出口，出口转关，属报岸放的，禁用集装箱类型
    if (declare_id == 1 || declare_id == 3 || declare_id == 5) {
        grid1.getColumn(6).readOnly = true;
    }

    if (declare_id == 1) {
        if (mini.get("txtswipe_deal_with_remark") != null) {
            document.getElementById("txtswipe_deal_with_remark$text").style.color = "red"; //蛇口刷卡异常字体变红
        }

    }

    //默认选中商品表体
    var tabs = mini.get("tabs2");
    if (declare_id != "3" && declare_id != "4")//进口转关，出口转关 不默认商品表体
        tabs.activeTab(tabs.tabs[1]);
    HideGoodsColumns();

    //流水号值改变事件 默认转换成大写
    var serial_no = mini.get("txtserial_no");
    if (serial_no != null) {
        mini.get("txtserial_no").on("valuechanged", function (e) {
            var value = e.value.toUpperCase();
            mini.get("txtserial_no").setValue(value);
            mini.get("txtcabin_no").setValue(value);
        });
    }
    var recordNum = mini.get("txtRecordNum");
    if (recordNum != null) {
        recordNum.on("blur", function (e) {
            if (fnCheckRecord(recordNum.getValue()) > 0) {
                mini.alert("合理审查记录单必须是10位！", "信息提示", function () {
                    recordNum.focus();
                });

            }
        });
    }

    /**********************************
    * add by zengtongchun 2016-06-17  改船校验是否重新平台取数
    **************************************/
    var shipState = mini.get("chkchange_yn");
    if (shipState != null) {
        shipState.on("valuechanged", function (e) {
            var val = shipState.getValue();
            var wharfId = mini.get("autwharf_id").getValue();
            //改船并且码头是SCT CCT MCT SKP MW DCD （重新平台取数）
            if (val == 1 && (wharfId == 10239 || wharfId == 10240 || wharfId == 10241 || wharfId == 10242 || wharfId == 10244 || wharfId == 10245)) {

                PlatForm();
            }
        });
    }

    ///其他事项确认
    var cobrelationshipYn = mini.get("cobrelationship_yn");
    if (cobrelationshipYn != null) {
        cobrelationshipYn.on("valuechanged", function (e) {
            var val = cobrelationshipYn.getValue();
            if (val == "1") {
                mini.get("chkPrice").setEnabled(true);
                mini.get("chkPrice").focus();
            } else {
                mini.get("chkPrice").setEnabled(false);
                mini.get("chkPrice").setValue('');
            }
        });
    }
    //支付特许权使用费确认
    var cobpayYn = mini.get("cobpay_yn");
    if (cobpayYn != null && mini.get("hidtransport_way").getValue() == "02") {
        cobpayYn.on("keydown", function (e) {
            fnBeginContainer();
        });
    }

    ////指运港焦点事件 运抵国有数据  显示运抵国带出的数据 否则查询所有数据 add by zhongxx 2016-05-06
    var autloadport_no = mini.get("autloadport_no");
    autloadport_no.on("focus", function (e) {
        var startCountryValue = mini.get("autstart_country_no").getValue();  //运抵国  getText
        var loadportName = mini.get("autloadport_no");  //指运港
        var url = "";
        if (startCountryValue == "" || startCountryValue == null || mini.get("hidtransport_way").getValue() == "02") {
            url = "../Share/GetJsonList?tablename=v_data_base_dictionary_detail&fieldnames=value,(value + %2B + '/' + %2B + name) as name&where=code='bg_zhiyungang'&searchField=name,value";
        } else {
            url = "../Share/GetJsonList?tablename=v_data_base_dictionary_detail&fieldnames=value,(value + %2B + '/' + %2B + name) as name&where=code='bg_zhiyungang' and help_code=" + startCountryValue + "  &searchField=name,value";
        }
        loadportName.setUrl(url);
    });


    ////指运港keydown事件 显示运抵国带出的数据 否则查询所有数据 add by zhongxx 2016-05-06
    autloadport_no.on("keydown", function (e) {
        var loadportNoData = mini.get("autloadport_no");
        if (loadportNoData.data.length == 0) {
            var loadportNo = loadportNoData.getText();  //指运港

            var loadportNoIndex = loadportNo.indexOf('/');
            if (loadportNoIndex < 0) {
                if (e.htmlEvent.keyCode == "13") { //回车键
                    $.ajax({
                        url: "/CustomsClearance/GetLoadportName?loadportNo=" + loadportNo,
                        cache: false,
                        async: false,
                        success: function (text) {
                            var result = text.split("/");
                            mini.get("autloadport_no").setText(text);
                            mini.get("autloadport_no").setValue(result[0]);

                            mini.get("autend_country_no").focus();
                        },
                        error: function () {
                            mini.alert("数据异常！");
                        }
                    });
                }
            }
        }
    });

    //---------------键盘s重新获取自编号 add by zengtongchun 2016-06-18 begin------------------------
    var useNo = mini.get("txtSelfNumbering");
    if (useNo != null) {
        useNo.on("keydown", function (e) {
            //键盘s
            if (e.htmlEvent.keyCode == "83") {
                var id = mini.get("id").value;
                var data = fnGetEntityInstance("t_mains", "id=" + id);
                if (data == null) {
                    mini.alert("请先保存报关单！");
                } else {
                    var nowUseNoExist = null;
                    if (useNo.getValue() != "") {
                        nowUseNoExist = fnGetData("t_mains", "self_numbering='" + useNo.getValue() + "'");
                        if (nowUseNoExist.data.length == 1) {
                            mini.alert("自编号唯一,无需获取！");
                            return;
                        }
                    }
                    //自编号存在就带本身自编号出来
                    if (data.self_numbering != "") {
                        mini.get("txtSelfNumbering").setValue(data.self_numbering);
                        return;
                    }


                    //自编号为空时，或自编号不存在时
                    if (useNo.getValue() == "" || nowUseNoExist == null) {
                        var msg = mini.loading("自编号重新获取中.............");
                        var newUseNo = fnGetCustomerCode();
                        mini.get("txtSelfNumbering").setValue(newUseNo);
                        mini.hideMessageBox(msg);
                        fnSaveUseNo(id, newUseNo);
                    }

                }

            }

        });
        useNo.on("blur", function (e) {
            var nowUseNo = useNo.getValue().replace("S", "").replace("s", "");
            useNo.setValue(nowUseNo);
        });
    }
    //---------------键盘s重新获取自编号 add by zengtongchun 2016-06-18 end------------------------

    //---------------通关状态获取 add by zengtongchun 2016-05-26 begin------------------------
    var btnPass = mini.get("btnTong");
    if (btnPass != null) {
        btnPass.on("click", function (e) {
            if (GetQPConfigExist() == "") {
                mini.alert("未配置qp操作权限！");
                return;
            }
            var id = mini.get("id").value; //cbtype 报关单类型（进，出口）
            $.ajax({
                url: "GetQpstatus",
                type: "get",
                async: false,
                data: { id: id },
                cache: false,
                success: function (result) {
                    var json = mini.decode(result);
                    if (json.FLAG == "true")
                        mini.get("txtqpstatus").setValue(json.RESULT);
                    else
                        mini.alert(json.MESSAGE);
                    //mini.get("txtqpstatus").setValue(result);
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                }
            });
        });
    }

    //---------------通关状态获取 add by zengtongchun 2016-05-26 end------------------------

    //---------------通关单状态获取 add by zengtongchun 2016-05-26 begin------------------------
    var btnPassorder = mini.get("btnTong1");
    if (btnPassorder != null) {
        btnPassorder.on("click", function (e) {
            if (GetQPConfigExist() == "") {
                mini.alert("未配置qp操作权限！");
                return;
            }
            var id = mini.get("id").value; //cbtype 报关单类型（进，出口）
            $.ajax({
                url: "GetTgdstatus",
                type: "get",
                async: false,
                data: { id: id },
                cache: false,
                success: function (result) {
                    var json = mini.decode(result);
                    if (json.FLAG == "true")
                        mini.get("txttgdstatus").setValue(json.RESULT);
                    else
                        mini.alert(json.MESSAGE);
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    //console.log(jqXHR);
                    mini.alert(jqXHR.responseText);
                }

            });
        });
    }

    //---------------通关单状态获取 add by zengtongchun 2016-05-26 end------------------------

    //---------------备案号取数 add by zengtongchun 2016-05-26 begin------------------------
    var records_no = mini.get("txtrecords_no");
    if (records_no != null) {
        records_no.on("enter", function (e) {
          
            if (GetQPConfigExist() == "") {
                mini.alert("未配置qp操作权限！");
                return;
            }
            var records_no = mini.get("txtrecords_no").value;
            if (records_no == null || records_no == '')
                return false;
            var messageid = mini.loading("正在QP取数中", "正在QP取数中");
            $.ajax({
                url: "GetRecordsInfo",
                type: "get",
                async: true,
                timeout: 10000,
                data: { id: id, records_no: records_no },
                cache: false,
                success: function (result) {
                    var data1 = mini.decode(result.Data);
                    mini.get("autshipper_name").setText(data1.TRADE_NAME);//经营单位名称
                    mini.get("autshipper_name").setValue(data1.TRADE_NAME);//经营单位名称
                    mini.get("txtshipper_no").setValue(data1.TRADE_CODE);//经营单位编号

                    var shopperNos = GetShipperNo(data1.TRADE_CODE);
                    if (shopperNos.length > 0) {
                        mini.get("cobrelationship_yn").setValue(shopperNos[0].relationship_yn); //特殊关系确认
                        mini.get("chkPrice").setValue(shopperNos[0].price_yn); //价格影响确认
                        mini.get("cobpay_yn").setValue(shopperNos[0].pay_yn);   //支付特许权使用费确认

                        mini.get("txtdrawback_dt").setValue(shopperNos[0].exp_dt);   //	带出通关期限
                    }

                    //mini.get("autconsignee_name").setText(data1.OWNER_NAME);//发货单位名称
                    mini.get("autconsignee_name").setValue(data1.OWNER_NAME);
                    mini.get("txtconsignee_no").setValue(data1.OWNER_CODE);//发货单位编号


                    mini.get("txtcontract_no").setValue(data1.CONTRNO);//合同协议号
                    GetSelectText('auttrade_no', data1.TRADE_MODE);//监管方式
                    GetSelectText('autimposemode_no', data1.CUT_MODE);//征免性质
                    GetSelectText('autend_country_no', data1.DISTRICT_CODE);//境内货源地/目的地
                    // alert("备案号到期时间为：" + data1.END_DATE);
                    //mini.alert(text);
                    mini.hideMessageBox(messageid);
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    //console.log("1111111111111111");
                    //console.log(XMLHttpRequest.status);
                    //console.log("22222222222222222222");
                    //console.log(XMLHttpRequest.readyState);
                    //console.log("33333333333333333");
                    //console.log(textStatus);
                    if (textStatus === "timeout") {
                        mini.alert("QP繁忙请稍后再试");
                    } else {
                        alert(jqXHR.responseText);
                    }
                    mini.hideMessageBox(messageid);
                }
            });
            mini.get("txtapply_dt").focus();
        });
    }

    //---------------备案号取数 add by zengtongchun 2016-05-26 end------------------------

    /**********************************
* add by zhongxx 2016-05-20   手动取【刷卡时间】
**************************************/

    var btnSwipt = mini.get("btnSwipt");
    if (btnSwipt != null) {
        btnSwipt.on("click", function (e) {

            var id = mini.get("id").getValue();
            if (id == "" || id == null) {
                mini.alert("主键id不能为空！！");
                return;
            }
            var messageid = mini.loading("正在获取刷卡时间中", "正在获取刷卡时间中");
            $.ajax({
                url: "GetSwiptDt",
                type: "get",
                data: { id: id },
                async: true,
                timeout: 10000,
                cache: false,
                success: function (result) {
                    if (result != "") {
                        mini.alert(result);
                        SetData({ id: id });
                    }
                    mini.hideMessageBox(messageid);
                },
                error: function (jqXHR, textStatus, errorThrown) {
                    if (textStatus === "timeout") {
                        mini.alert("网络繁忙请稍后再试！");
                    } else {
                        alert(jqXHR.responseText);
                    }
                    mini.hideMessageBox(messageid);
                }
            });

        });
    }

    //收发货人回车事件  add by zhongxx 2016-06-22
    var shipperName = mini.get("autshipper_name");
    if (shipperName != null) {
        shipperName.on("enter", function (e) {
            getShipperNoValue();
        });
    }

    //---------------add by zhanyong 2016-07-26  发货单位 按【S】键 自动带出 【经营单位】值编码 begin------------------------
    var consigneeName = mini.get("autconsignee_name"); //消费使用单位
    if (consigneeName != null) {
        consigneeName.on("enter", function (e) {
            var consigneeNameValue = consigneeName.getValue();
            if (consigneeNameValue == "s" || consigneeNameValue == "S") { //S键
                var shipperName = mini.get("autshipper_name").getText();
                var shipperNo = mini.get("txtshipper_no").getValue();
                consigneeName.setValue(shipperName);
                mini.get("txtconsignee_no").setValue(shipperNo);
                mini.get("auttrade_no").focus();
                return;
            }
            if (mini.get("hidtransport_way").getValue() == "02") {
                var data = GetShipperNo(consigneeNameValue);
                if (data.length != 0) {
                    consigneeName.setValue(data[0].znamec);
                    mini.get("txtconsignee_no").setValue(data[0].zucode);
                }
            }

        });
    }
    //---------------add by zhanyong 2016-01-09  发货单位 按【S】键 自动带出 【经营单位】值编码 end------------------------

}


// 通过经营单位编号带出 特殊关系确认、价格影响确认、支付特许权使用费确 add by zhongxx 2016-06-16
function GetShipperNo(shipperNo) {
    var result = new Array();
    $.ajax({
        url: "/CustomsClearance/GetShipperNo",
        cache: false,
        async: false,
        data: { shipperNo: shipperNo },
        success: function (text) {
            result = mini.decode(text);
        },
        error: function () {
            mini.alert("数据异常！");
        }
    });
    return result;
}


/**********************************
* add by zhanyong 2015-04-27选择 【经营单位】联动【经营单位编码】
* update by zengtongchun 2015-06-11
* update by 钟星星 2016-05-11-选择
**************************************/

function onShipperNameclick(e) {
    var obj = mini.get("autshipper_name");
    var data = obj.data;//获取当前绑定数据
    var nowValue = obj.getValue();
    var busType = mini.get("hidtransport_way").getValue();
    for (var i = 0; i < data.length; i++) {
        if (data[i].zucode == nowValue) {
            
            mini.get("txtshipper_no").setValue(data[i].zucode);
            mini.get("txtshipper_grade").setValue(data[i].com_iden);
            mini.get("txtdrawback_dt").setValue($.trim(data[i].exp_dt));
            if (busType != "03" && busType != "01") {//空运海运不联动
                mini.get("txtconsignee_no").setValue(data[i].zucode);
                mini.get("autconsignee_name").setValue(data[i].znamec);
                mini.get("autconsignee_name").setText(data[i].znamec);
            }
           

            mini.get("cobrelationship_yn").setValue(data[i].relationship_yn); //特殊关系确认
            mini.get("chkPrice").setValue(data[i].price_yn); //价格影响确认
            mini.get("cobpay_yn").setValue(data[i].pay_yn);   //支付特许权使用费确认
            //陆运专用
            var shipperOrConsignee = mini.get("txtshipper_consignee");
            if (shipperOrConsignee != null && busType == "02") {
                if (declareId==1) {//出口收货人
                    shipperOrConsignee.setValue(data[i].consignee);
                }
                else if (declareId == 2) {//进口发货人
                    shipperOrConsignee.setValue(data[i].shipper);
                }
            }
            // mini.get("autconsignee_name").setText(data[i].znamec);
            //只有长安标致雪铁龙汽车有限公司 粘贴显示全部
            if (nowValue == "4403137936" && data[i].znamec == "长安标致雪铁龙汽车有限公司") {
                var pasteTypeAll = [{ text: "报关单头", value: "1" }, { text: "报关单商品", value: "2" }, { text: "全部(不含柜号)", value: "3" }, { text: "全部", value: "4" }];
                mini.get("rbl").setData(pasteTypeAll);
            } else {
                var pasteType = [{ text: "报关单头", value: "1" }, { text: "报关单商品", value: "2" }, { text: "全部(不含柜号)", value: "3" }];
                mini.get("rbl").setData(pasteType);
            }
            obj.setValue(data[i].znamec);
            break;
        }
    }

}

function onConsigneeNameclick(e) {
    var selectedVal = e.selected;
    var obj = mini.get("txtconsignee_no");
    obj.setValue(selectedVal.zucode);
}


//add by zengtongchun 2016-08-14
function fnSetDefaultTransWay() {
    if (mini.get("hidtransport_way").getValue() == "01") {

        mini.get("autentry_type").setValue("M");//出口默认通关无纸化
        mini.get("autentry_type").setText("M/通关无纸化");//出口默认通关无纸化
        mini.get("auttransmode_no").setValue("2");//出口默认通关无纸化  2/水路运输
        mini.get("auttransmode_no").setText("2/水路运输");//出口默认通关无纸化
        return;
    }
    if (mini.get("hidtransport_way").getValue() == "02") {

        mini.get("autentry_type").setValue("M");//出口默认通关无纸化
        mini.get("autentry_type").setText("M/通关无纸化");//出口默认通关无纸化
        mini.get("auttransmode_no").setValue("4");//出口默认通关无纸化  4/公路运输
        mini.get("auttransmode_no").setText("4/公路运输");//出口默认通关无纸化

        mini.get("autport_name").setText("皇岗海关");
        mini.get("txtport_no").setValue("5301");
        mini.get("autapply_port_no").setText("5301/皇岗海关");
        mini.get("autapply_port_no").setValue("5301");
        return;
    }
    if (mini.get("hidtransport_way").getValue() == "03") {
        mini.get("autentry_type").setValue("M");//出口默认通关无纸化
        mini.get("autentry_type").setText("M/通关无纸化");//出口默认通关无纸化
        mini.get("auttransmode_no").setValue("5");//出口默认通关无纸化  4/公路运输
        mini.get("auttransmode_no").setText("5/航空运输");//出口默认通关无纸化
    }
    if (mini.get("hidtransport_way").getValue() == "04") {//关务制单默认mct码头
        mini.get("autwharf_id").setText("MCT/MCT码头");
        mini.get("autwharf_id").setValue("10245");
    }
}
//开始编辑 集装箱信息
function fnBeginContainer() {

    var tabs = mini.get("tabs2");
    tabs.activeTab(tabs.getTab(0));
    var grid = mini.get("datagrid1");
    var firstrow = grid.data[0];
    grid.beginEditCell(firstrow, "container_type_no");
}


/**********************************
* add by zhanyong 2015-05-14  为报关单 【集装箱信息】【商品信息】 表体增加   t_main_id 字段
**************************************/

function addt_main_id(data, id) {
    for (var i = 0; i < data.length; i++) {
        data[i].t_main_id = id;
        // data[i].id = '';
    }
    return data;
}

/**********************************
* add by zhanyong 2015-05-12 获得报关单ID
**************************************/

function GetId() {
    var result = "";
    $.ajax({
        url: "GetCustomersClearanceMaxId",
        type: "get",
        async: false,
        data: {},
        cache: false,
        success: function (text) {
            result = text;
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert(jqXHR.responseText);
        }
    });
    return result;
}


//保存自编号 add by zengtongchun 2016-06-30
function fnSaveUseNo(id, useNo) {
    $.ajax({
        url: "/CustomsClearance/SaveUseNo",
        async: false,
        data: { id: id, useNo: useNo },
        cache: false,
        success: function (result) {
            SetData({ id: id });
        }
    });
}
//非华为合理审查记录单 add by ztc 2016-08-29
function fnCheckRecord(num) {
    var exist = 0;
    if ($.trim(num).length != 10) {
        exist = 1;
    }
    return exist;
}

// add by zengtongchun 2015-06-16 流水号纠错
function fnJiuCuo() {
    mini.confirm("确定：是，取消：否。", "是否重置编号？",
        function (action) {
            var id = mini.get("id").getValue();//获取报关单id
            var no = mini.get("txtserial_no").getValue();//获取流水号id
            if (mini.get("txtserial_no").getInputText() != "") {
                no = mini.get("txtserial_no").getInputText();
            }
            var url = null;
            if (action == "ok") {
                url = "../BusZhiDan/Jiucuo?id=" + id + "&no=" + no + "&yn=1";//重置编号
            } else {
                url = "../BusZhiDan/Jiucuo?id=" + id + "&no=" + no + "&yn=0";
                return;
            }
            $.ajax({
                url: url,
                type: "get",
                async: false,
                data: {},
                cache: false,
                success: function (result) {
                    mini.alert(result);
                    SetData({ id: id });
                }
            });
        }
    );

}


//联动运抵国下拉选择带出对应的指运港 add by zhongxx 2016-05-05
function onYunDiGuoChanged(e) {
    var startCountryValue = mini.get("autstart_country_no").getValue();  //运抵国
    var startCountryText = mini.get("autstart_country_no").getText();  //运抵国
    var portWay = mini.get("hidtransport_way").getValue();
    if (declareId == 1 && portWay != "03" && portWay != "02") {  //如果是出口带出贸易国  空运不要联动
        mini.get("auttrade_country_no").setValue(startCountryValue);//出口默认通关无纸化  2/水路运输
        mini.get("auttrade_country_no").setText(startCountryText);//出口默认通关无纸化
    }

}
/**********************************
* add by zengtongchun 2016-06-18 获取自编号
**************************************/
function fnGetCustomerCode() {
    var useNo = "";
    $.ajax({
        url: "GetCustomerCode",
        type: "get",
        async: false,
        data: { type: declareId },
        cache: false,
        success: function (data) {
            useNo = data;
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert(jqXHR.responseText);
        }
    });
    return useNo;
}
//陆运默认给集装箱数和柜号 add by zengtongchun 2016-08-09
function fnLYAddContainerInfo(className) {
    mini.get("txtcontainer_count").setValue("1");
    var containerNo = "";
    if (className=="02") {
        containerNo = "LKDEFAULT";
    }
    var defaultContainerInfo = { id: "0", num_no: "1", container_no: containerNo, container_type_no: "40", fee_type: "F" };
    mini.get("datagrid1").clearRows();
    mini.get("datagrid1").addRow(defaultContainerInfo);
}


/**********************************
* add by zengtongchun 2016-06-18 获取当前前缀下最新的流水号
**************************************/
function fnGetNewUseNo() {
    var differenceInt = 1;//默认连续相差1
    $.ajax({
        url: "GetNewUseNo",
        type: "get",
        async: false,
        data: { type: declareId, id: id },
        cache: false,
        success: function (data) {
            var oldData = parseInt(data);
            var nowUseNo = mini.get("txtSelfNumbering").getValue();
            if (nowUseNo != "") {
                var num = parseInt(nowUseNo.substr(nowUseNo.length - 5));
                differenceInt = num - oldData;
            }
        },
        error: function (e) {

        }
    });
    return differenceInt;
}

//回车带出通关期限
function getShipperNoValue() {
    var shipperName = mini.get("txtshipper_no").getValue();
    var data = GetShipperNo(shipperName);

    mini.get("txtshipper_no").setValue(data[0].zucode);
    mini.get("txtshipper_grade").setValue(data[0].com_iden);
    mini.get("txtdrawback_dt").setValue($.trim(data[0].exp_dt));
    mini.get("txtconsignee_no").setValue(data[0].zucode);
    mini.get("autconsignee_name").setValue(data[0].znamec);

    mini.get("cobrelationship_yn").setValue(data[0].relationship_yn); //特殊关系确认
    mini.get("chkPrice").setValue(data[0].price_yn); //价格影响确认
    mini.get("cobpay_yn").setValue(data[0].pay_yn);   //支付特许权使用费确认

}


//进口成交方式true为显示 false为隐藏 数组对应成交方式值改变时的显示隐藏效果
/**********************************
       * add by zengtongchun 2015-6-1 初始成交方式全为不可填写
   **************************************/
//需要隐藏or显示的id号  1 CIF 2 C&F  3 FOB  4 C&I  5 市场价 6 垫仓
var str = ["autfreightmode_no", "txtfreight", "autfreight_currency_no", "autsubscribemode_no", "txtsubscribe", "autsubscribe_currency_no", "autincidentalmode_no", "txtincidental", "autincidental_currency_no"];

function fnSetDisabled() {
    for (var i = 0; i < str.length; i++) {
        mini.get(str[i]).setEnabled(false);
    }

}
//循环判断隐藏or显示
function fnChangeDisabled(arry) {

    fnSetDisabled();
    var newArray = arry;
    for (var i = 0; i < arry.length; i++) {
        if (newArray[i]) {
            mini.get(str[i]).setEnabled(true);
        }
    }

}
//获取报关单费用支出项 add by zengtongchun 2015-09-29
function GetPayCost() {
    var cost = [];
    var wharf_cost = GetEntityData('fn_pay_wharf_cost');
    var protect_cost = GetEntityData('fn_pay_protect_cost');
    var check_cost = GetEntityData('fn_pay_check_cost');
    var lihuo_cost = GetEntityData('fn_pay_lihuo_cost');
    var bh_cost = GetEntityData('fn_pay_bh_cost');
    var fees = { id: '', t_main_id: mini.get("id").getValue(), wharf_cost: wharf_cost, protect_cost: protect_cost, lihuo_cost: lihuo_cost, check_cost: check_cost, bh_cost: bh_cost };
    cost.push(fees);
    return cost;
}

//根据配置费用获取配置 add by zengtongchun 2015-09-30
function GetEntityData(code) {
    var cost = 0;
    var entityData = fnGetSingleData("v_data_base_dictionary_detail", "code='" + code + "'");
    if (datafee==null) {
        return cost;
    }
    var countData = datafee;
    for (var i = 0; i < entityData.length; i++) {
        for (var j = 0; j < countData.length; j++) {
            if (entityData[i].value == countData[j].fee_cd) {
                cost += countData[j].z_cost;
            }
        }
    }
    return cost;
}


//获取费用列表
function GetFeesList(id) {
    $.ajax({
        url: "/FeesAudit/GetFeesAudit?mainsid=" + id,
        cache: false,
        async: false,
        success: function (text) {
            var result = mini.decode(text); //反序列化成对象
            datafee = mini.decode(result.Data.feesaudit);
        },
        error: function () {
            mini.alert("数据异常！");
        }
    });
}
//获取qp配置是否存在 add by zengtongchun 2016-05-26
function GetQPConfigExist() {
    var str = "";
    $.ajax({
        url: "/CustomsClearance/GetQPConfigExist",
        cache: false,
        async: false,
        success: function (text) {
            str = text;
        },
        error: function () {
            mini.alert("数据异常！");
        }
    });
    return str;
}


/**********************************
* add by zhanyong 2015-04-23 绑定下拉框数据源
**************************************/

function Binding(id, tablename, fieldnames, where) {
    var json = { tablename: tablename, fieldnames: fieldnames, where: where };
    $.ajax({
        url: "GetJson",
        context: document.body,
        data: json,
        success: function (data) {
            var result = mini.decode(data.Data);
            mini.get(id).load(result);
        }
    });
}

/**********************************
* add by zhanyong 2015-04-23 清空客户
**************************************/
function onCloseClick(e) {
    var obj = e.sender;
    obj.setText("");
    obj.setValue("");
}
function onCustomerClick(e) {
    Binding("cmbCustomer", "t_base_objs", "zucode,znamec", "");
}

/**********************************
* add by zhanyong 2015-05-05 面板切换时发生
**************************************/
function tabChange(e) {
    if (e.tab.title == "查验信息") {
        var data = mini.get("datagrid1").data;
        var newdata = mini.clone(data);
        mini.get("datagrid5").setData(newdata);
    }
}
//从数据库校验当前集装箱是否对碰了港保费 add by zengtongchun 2016-05-19
function fnIsContainerChange() {
    var num = 0;
    //mini.get("id").getValue()
    $.ajax({
        url: "/CustomsClearance/CheckCostTouch?id=" + id,
        cache: false,
        async: false,
        success: function (text) {
            num = text;
        },
        error: function () {
            mini.alert("数据异常！");
        }
    });
    return num;
}

//集装箱数改变时
function containercountchage(e) {
    if (fnIsContainerChange() > 0) {
        mini.alert("集装箱已对碰港保费，要操作请联系财务处理！");
        return;
    }
    var count = parseInt(e.value);  //集装箱数
    var tabs = mini.get("tabs2");
    tabs.activeTab(tabs.getTab(0));

    var grid = mini.get("datagrid1");
    var index = grid.data.length;
    for (var i = index + 1; i <= count; i++) {
        var newRow = null;
        if (declareId == 2 || declareId == 4) {//进口
            newRow = { id: 0, num_no: i, fee_type: 'F', fee_yn: 1 };
        } else {
            newRow = { id: 0, num_no: i };
        }

        grid.addRow(newRow, i);
    }
    if (index != 0) {
        SetContainerNum();
    }

    //开始编辑 集装箱信息
    var firstrow = grid.data[0];
    grid.beginEditCell(firstrow, "container_type_no");

}
//集装箱序号重新排列 add by zengtongchun 2016-04-01
function SetContainerNum() {
    var grid = mini.get("datagrid1");
    var nums = grid.data.length;
    for (var i = 0; i < nums; i++) {
        var row = grid.data[i];
        grid.updateRow(row, { num_no: i + 1 });
    }
}



function fnIsHuaAdd(trans) {
    var customerObj = fnGetEntityInstance("v_t_base_objs", "id=891419");
    var code = "5301";
    if (trans=="03") {
        code = "5317";
    }
    var portObj = fnGetEntityInstance("v_data_base_dictionary_detail", "value='" + code + "'");
    if (customerObj != null) {
        mini.get("autcustomer_name").setText(customerObj.short);
        mini.get("hidcustomer_id").setValue(customerObj.id);
    }
    if (portObj != null) {
        mini.get("autport_name").setText(portObj.name);
        mini.get("txtport_no").setValue(portObj.value);
        mini.get("autapply_port_no").setText(portObj.name);
        mini.get("autapply_port_no").setValue(portObj.value);
    }
}

//页面加载弹出合理审查记录单 add by zengtongchun 2016-06-17
function RecordNumClick() {
    mini.open({
        url: "../CustomsClearance/RecordNum?id=" + id,
        title: "合理审查记录单",
        width: 350,
        height: 130,
        allowResize: false,
        onload: function () {       //弹出页面加载完成
            var iframe = this.getIFrameEl();
            var trans = mini.get("hidtransport_way").getValue();
            var data = { isHw: isHw, declareId: declareId, trans: trans };
            if (isHw == "1" && (trans == "02" || trans == "03")) {
                fnIsHuaAdd(trans);
            }
            //调用弹出页面方法进行初始化
            iframe.contentWindow.SetData(data);

        },
        ondestroy: function (action) {  //弹出页面关闭前
            if (action == "ok") {       //如果点击“确定”
                var iframe = this.getIFrameEl();
                //获取选中、编辑的结果
                var data = iframe.contentWindow.GetData();
                data = mini.clone(data);    //必须。克隆数据。
                mini.get("txtRecordNum").setValue(data.recordNum);
                mini.get("txtbus_no").setValue(data.businessNo);
                mini.get("txtcabin_no").setValue(data.cabinNo);
                isContinue = data.isContinue;
                if (data.businessNo!=""&&isHw=="1"&&declareId==1) {
                    fnHuaWeiExportAddDefault(data.businessNo);
                }
                if (isContinue == 1 && mini.get("autcustomer_name").getText() != "" && isHw == "1") {
                    fnSaveCommonData();

                }

            }
            mini.get("autcustomer_name").focus();
        }
    });
}

function fnHuaWeiExportAddDefault(bus_no) {
    var defaultHuaWeiExport = [
        { prefix: "HW", shipper_name: "华为技术有限公司" },
        { prefix: "HM", shipper_name: "华为终端有限公司" },
        { prefix: "DG", shipper_name: "华为终端（东莞）有限公司" },
        { prefix: "HS", shipper_name: "深圳市海思半导体有限公司" }
    ];
    var bus_prefix = bus_no.substr(0, 2).toUpperCase();
    for (var i = 0; i < defaultHuaWeiExport.length; i++) {
        if (defaultHuaWeiExport[i].prefix==bus_prefix) {
            var data = fnGetEntityInstance("t_base_companies", "znamec='" + defaultHuaWeiExport[i].shipper_name + "'");
            if (data != null) {
                mini.get("autshipper_name").setValue(data.zucode);
                mini.get("autshipper_name").setText(data.znamec);
                mini.get("txtshipper_no").setValue(data.zucode);
                mini.get("autconsignee_name").setValue(data.znamec);
                mini.get("txtconsignee_no").setValue(data.zucode);
                mini.get("txtdrawback_dt").setValue(data.exp_dt);
            }
        }
    }
    
}

function HideGoodsColumns() {
    var datagrid2 = mini.get("datagrid2");
    var declareId1 = mini.get("hiddeclare_id").getValue();
    if (declareId1 == 2) {//进口
        datagrid2.updateColumn("country_name", { header: "原产国(地区)" });
        datagrid2.updateColumn("final_country_name", { header: "最终目的国（地区）" });
    }

}
//获取海陆空前缀 add by zengtongchun 2016-03-26
function GetPrefix() {
    var billNo = mini.get("txtbill_no").getValue();//工作号
    var prefix = "";//海运、陆运、空运前缀
    if (billNo.length != 0) {
        prefix = billNo.substr(0, 2);
    }
    else {
        var prefixVal = mini.get("hidPrefix").getValue();
        if (prefixVal.length != 0) {
            prefix = prefixVal.substr(0, 2);
        }
    }
    return prefix.toUpperCase();
}

//交单后要禁止的按钮 add by zengtongchun 2016-03-07
//要禁用的按钮id
var enableButtonsByCompleteYn = ["btnLogic", "btnQpInput", "btnQpDownload", "btnGoodsExport", "btnLock", "btnPlatInfo", "btnJiuCuo"];
function SetEnableButtons() {

    for (var i = 0; i < enableButtonsByCompleteYn.length; i++) {
        if (mini.get(enableButtonsByCompleteYn[i]) != null) {
            mini.get(enableButtonsByCompleteYn[i]).setEnabled(false);
        }

    }
}

//解除交单后禁止的按钮 add by zengtongchun
function SetDeEnableButtons() {
    for (var i = 0; i < enableButtonsByCompleteYn.length; i++) {
        if (mini.get(enableButtonsByCompleteYn[i]) != null) {
            mini.get(enableButtonsByCompleteYn[i]).setEnabled(true);
        }

    }
}

//设置qp记录信息 add by zengtongchun 2016-07-08
function SetQpRecord(dataQpRecord) {
    var fnName = [{ name: "qpinput", text: "上传" },
        { name: "qpreturn", text: "下载" },
        { name: "GetGoodsInfoByRecordsNo", text: "商品项号" },
        { name: "GetRecordsInfo", text: "备案号" },
        { name: "GetQpstatus", text: "通关状态" }
    ];
    var miniQpRecord = mini.get("dataQpRecord");
    for (var i = 0; i < dataQpRecord.length; i++) {
        for (var j = 0; j < fnName.length; j++) {
            if ($.trim(dataQpRecord[i].call_mother_name) == fnName[j].name) {

                dataQpRecord[i].call_mother_name = fnName[j].text;
            }
        }
    }

    miniQpRecord.setData(dataQpRecord);

}

function fnQpSendInfo(id) {
    var data = fnGetData("t_apply_no_status_call_log", "t_main_id=" + id);
    if (data!=null) {
        var dataQpSendRecord = mini.get("dataQpSendRecord");
        dataQpSendRecord.setData(data.data);
    }
    
}

//获取报关单版本记录 add by zengtongchun 2016-07-24
function GetMainsVersion(id, t_main_id) {
    var versionData = fnGetEntityInstance("v_t_mains_version", "id=" + id + " and t_main_id=" + t_main_id);
    var jsonData = mini.decode(versionData.json_str.replace(new RegExp(/(:,)/g), ":null,").replace(new RegExp(/(:})/g), ":null}"));
    HideButtons();
    return mini.decode(jsonData);
}

function HideButtons() {
    var buttons = $(".mini-button");
    for (var i = 0; i < buttons.length; i++) {
        var id = buttons[i].id;
        if (id != "") {
            mini.get(id).setEnabled(false);
        }
    }
}

//编辑下一条数据之前清空之前的变量
function Clear() {
    span = null;
    inputs = null;
    accompany_details = [];//随附单据
    // roleId = "@ViewBag.Role";//当前用户角色
    //declareId = mini.get("hiddeclare_id").getValue();//进出口类型
    datafee;
    description = mini.get("hidtype").getValue();
    // id = '@ViewBag.ID';//当前报关单ID 
    // RoleStr = '@ViewBag.RoleStr';//费用角色串
    //  barcode_no = '@ViewBag.Barcode_no';  //值为工作号或者报关单号组合
    //   empId = '@ViewBag.loginId';//当前登录人ID 
    //  record = '@Request["record"]';//报关单版本ID 
    //  isHw = '@Request["isHw"]';//是否华为
    port_no = "";//口岸编码
    isContinue = 0; //继续新增
    //  isQpInput = '@ViewBag.IsQpInput'; //陆运整理岗，制单岗没有qp上传权限
    // isview = '@ViewBag.Isview'; //查询报关单隐藏操作按钮


    var form = new mini.Form("#form1");
    form.clear();
    fnClearOtherCost();//清空其他费用

}


/**********************************
* add by zhanyong 2015-05-08 编辑报关方法
**************************************/
function SetData(data) {

    var nowId = data.id;
    var code = data.barcode_no;
    $.ajax({
        url: "Edit",
        type: "get",
        data: { id: nowId, barcode_no: code, transPort: mini.get("hidtransport_way").getValue() },
        cache: false,
        //async:false,
        success: function (text) {
            var setVersion = 0;
            var operator_type = 0;
            if (data != null && data.operator_type != null) {
                setVersion = 1;
                operator_type = data.operator_type;
            }
            data = text;
            //console.log(data);
            //-----------------------版本记录begin-----------------------------
            if (record != "") {
                data = GetMainsVersion(record, nowId);
            }
            //-----------------------版本记录end-----------------------------
            var t_mains = mini.decode(data.t_mains)[0];
            id = t_mains.id;
            SetQpRecord(mini.decode(data.qpRecord));
            fnQpSendInfo(id);
            if (setVersion == 1) {
                SetMainsVersion(t_mains.selfnumbering, t_mains.bill_no, mini.encode(data), operator_type, t_mains.declare_id);
            }

            //华为
            if (t_mains.customer_id == 891419) {
                isHw = 1;
            }
            var form = new mini.Form("#form1");

            var t_check_statuses = mini.decode(data.t_check_statuses);
            var costinfo = form.getData();
            t_mains = jQuery.extend(t_mains, t_check_statuses); //合并 报关单主表，查验信息
            t_mains = jQuery.extend(costinfo, t_mains); //合并 报关单主表，费用信息
            t_mains.id = id;
            port_no = t_mains.port_no;
            declareId = t_mains.declare_id;
            //交单时禁用的按钮
            if (t_mains.complete_yn == 1) {
                SetEnableButtons();
            } else {
                mini.get("btnQpDownload").setEnabled(true);
            }
            /*****************逻辑审核记录 begin***********************/
            var logicGrid = mini.get("dataLogicRecord");
            var logicRecord = mini.decode(data.logicRecord);
            logicGrid.setData(logicRecord);
            /*****************逻辑审核记录 end***********************/

            /*****************生成 其他事项确认 begin***********************/
            var promise_itmes = t_mains.promise_itmes;
            if (promise_itmes != null && promise_itmes.length >= 3) {
                t_mains["relationship_yn"] = promise_itmes.substr(0, 1);
                t_mains["price_yn"] = promise_itmes.substr(1, 1);
                t_mains["pay_yn"] = promise_itmes.substr(2, 1);
            }
            /*****************生成 其他事项确认 end***********************/

            $("#check_name").text(t_mains.check_name); //海关查柜员
            $("#check01_name").text(t_mains.check01_name); //商检查柜员

            form.setData(t_mains);

            if (t_mains.relationship_yn == 1) {
                mini.get("chkPrice").setEnabled(true);
            }
            /**************************报关单相关操作人begin************************/
            HideGoodsColumns();//隐藏商品列
            var processInfoData = mini.decode(data.processInfo);
            var bb = mini.get("txthgfx_dt");//海关放行时间
            //给海关放行时间(为了判断勾选海关放行是否已存在放行时间)
            for (var i = 0; i < processInfoData.length; i++) {
                if (processInfoData[i].operator_type == "12" || processInfoData[i].operator_type == "112" || processInfoData[i].operator_type == "212") {
                    bb.setValue(processInfoData[i].operator_dt);
                    break;
                }
            }

            fnSetProcessInfo(processInfoData, processInfoData.length);
            /**************************报关单相关操作人 end************************/

            /**************************设置页面的 autocomplate 控件的值 begin************************/
            $("#jsy_name").text(t_mains.jsy_name);//结算员
            if (t_mains.jsy_name == "" || t_mains.jsy_name == null) {
                SetJieSuan(t_mains.customer_id);//给结算员赋值
            }
            mini.get("txtshipper_grade").setValue(t_mains.com_iden);
            /*****************进口用途 Edit by zengtongchun begin 2015-07-06 begin***********************/
            if (declareId == 2) {//进口
                var txtfactory = mini.get("txtfactory");
                if (txtfactory != null) {
                    txtfactory.setText(t_mains.uses);//用途
                    txtfactory.setValue(t_mains.useno);//用途
                }
                var col = mini.get("datagrid2").columns;
                for (var i = 0; i < col.length; i++) {
                    if (col[i].header == "目的国") {
                        col[i].header = "原产国";
                        break;
                    }
                }
            }
            /*****************进口用途，不存在船代 Edit by zhuhy end 2015-07-06  end***********************/
            if (t_mains.bargainmode_no != "") {//成交方式不为空时加载隐藏显示
                var index = t_mains.bargainmode_no - 1;
                if (index >= 0) {
                    fnChengJiaoWay(index);
                }

            }
            /**************************设置页面的 autocomplate 控件的值 end************************/

            /**************************设置[集装箱表体][商品信息][随附单证][差错记录]  的值 begin************************/

            var t_details = mini.decode(data.t_details);
            CheckContainerTouchCost(t_details);
            var t_goods_details = mini.decode(data.t_goods_details);

            for (var i = 0; i < t_goods_details.length; i++) {
                t_goods_details[i].price = t_goods_details[i].price == null ? 0 : t_goods_details[i].price.toFixed(4);
            }
            var t_main_docs = mini.decode(data.t_main_docs);
            var t_work_errors = mini.decode(data.t_work_errors);
            var t_shipping_details = mini.decode(data.t_shipping_details);
            mini.get("id").setValue(id); //重新设置ID
            t_other_cost = mini.decode(data.t_other_cost);
            //设置通关单状态 鼠标浮上去就显示

            SetCostInfo(t_other_cost);
            accompany_details = mini.decode(data.t_accompany_details);
            /**************************设置[集装箱表体][商品信息][随附单证][差错记录]  的值 begin************************/
            mini.get("datagrid1").setData(t_details); //集装箱信息
            t_goods_details = fnSetGoodsClearZero(t_goods_details);
            mini.get("datagrid2").setData(t_goods_details); //商品信息
            mini.get("datagrid3").setData(t_main_docs); //随附单证
            mini.get("datagrid4").setData(t_work_errors); //差错记录

            var datagrid6 = mini.get("datagrid6");
            if (typeof (datagrid6) != "undefined") {
                mini.get("datagrid6").setData(t_shipping_details);//流水号记录
            }
            if (t_check_statuses != null) {
                if (t_check_statuses.check_yn == 1) {
                    mini.get("check_haiguang").setEnabled(true);
                }
                if (t_check_statuses.check01_yn == 1) {
                    mini.get("check_shangjian").setEnabled(true);
                }
                mini.get("check_statusesid").setValue(t_check_statuses.id); //保存成功 设置【查验信息】ID
            }


            CheckXuKeNumber();
            //继续新增
            if (isContinue == 1) {
                var isContinueObj = fnContinueObj();
                isContinueObj.id = GetId();
                id = isContinueObj.id;
                mini.get("id").setValue(id);
                form.setData(isContinueObj);
                fnSetDefaultTransWay();
                //重新给柜号默认值
                if (isContinueObj.transport_way == "02" || isContinueObj.transport_way == "03") { //只有陆运空运默认加集装箱
                    fnLYAddContainerInfo(isContinueObj.transport_way);
                }
                if (declareId == 1 || declareId == 2) {
                    RecordNumClick();
                }
                //已交单继续新增清除禁用按钮
                if (t_mains != null && t_mains.complete_yn == 1) {
                    SetDeEnableButtons();
                }
                fnClearOtherCost();
                accompany_details = [];//清除随附单证
                isContinue = 0;

            }
           
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert(jqXHR.responseText);
        }
    });
}

//继续新增清空其它费用信息 add by zengtongchun 2016-08-15
function fnClearOtherCost() {
    for (var i = 0; i < addCost.length; i++) {
        addCost[i].cost = 0;
    }
}

function SetMainsVersion(use_no, work_no, json_str, operator_type, declare_id) {

    $.ajax({
        url: "/CustomsClearance/SetMainsVersion",
        type: "post",
        data: { t_main_id: id, use_no: use_no, work_no: work_no, json_str: json_str, operator_type: operator_type, declare_id: declare_id },
        cache: false,
        success: function (text) {

        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert("Error" + jqXHR.responseText);
        }
    });
}

//进程信息分开显示设置 add by zengtongchun 2016-07-08
function fnSetProcessInfo(processInfoData, num) {
    var processInfo1 = mini.get("dataProcessInfo1");
    var processInfo2 = mini.get("dataProcessInfo2");
    var processData1 = [];
    var processData2 = [];
    for (var i = 0; i < processInfoData.length; i++) {
        if (i < num / 2) {
            processData1.push(processInfoData[i]);
        } else {
            processData2.push(processInfoData[i]);
        }
    }
    processInfo1.setData(processData1);
    processInfo2.setData(processData2);

}

//判断集装箱是否对碰港保费 add by zengtongchun 2016-05-18
function CheckContainerTouchCost(objList) {
    for (var i = 0; i < objList.length; i++) {
        //存在对碰的就锁死
        if (objList[i].wharf_yn == 1) {
            mini.get("datagrid1").setEnabled(false);
            mini.get("btnContainerAdd").setEnabled(false);
            mini.get("btnContainerDel").setEnabled(false);
            break;
        }
    }
}
//给结算员赋值 add by zengtongchun
function SetJieSuan(customer_id) {
    var jsyData = fnGetEntityInstance("v_get_jsy", "customer_id=" + customer_id);

    if (jsyData != null) {
        $("#jsy_name").text(jsyData.jsy_name);
        mini.get("txtJsy").setValue(jsyData.jsy_by);
    }
}

/**********************************
* add by zengtongchun 2015-07-06 通过判断报关类型加载不同的成交方式显示形式
**************************************/
function fnChengJiaoWay(index) {
    fnChangeDisabled(array[index]);//加载时判断出口成交方式隐藏方式
    //fnChangeDisabled(array[index]);//加载时判断进口成交方式隐藏方式
};
function fnCancle() {
    mini.get("editWindow").hide();
}


//截关日期自动补齐
$(document).on('keyup', 'body', function (e) {
    var endtext = "";
    if (e.target.id == "txtend_dt$text") {
        var txtend_dt = $("input[id^='txtend_dt']");
        endtext = txtend_dt.val();
        if (endtext.length == 4 || endtext.length == 7) {
            txtend_dt.val(endtext + "-");
        }
        if (endtext.length == 10) {
            txtend_dt.val(endtext + " ");
        }
        if (endtext.length == 13) {
            txtend_dt.val(endtext + ":");
        }
        if (endtext.length == 16) {
            txtend_dt.val(endtext + ":00");
            var end_dt = txtend_dt.val();
            mini.get("txtend_dt").setValue(end_dt);
            mini.get("txtqpstatus").focus();
        }
    }
});